﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Demo610
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //加载时就获取Session对象中的名为username的对象
            string username = (string)Session["username"];
            //判断获取的内容是否为空
            if (username!=null)
            {
                //在页面打印欢迎信息
                Response.Write($"<b>您的用户名为：{username}！</b>");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //获取Session对象中的名为username的对象
            string username = (string)Session["username"];
            //获取Session对象中的名为password的对象
            string password = (string)Session["password"];
            //判断用户输入的信息是否正确
            if (username== TextBox1.Text && password== TextBox2.Text)
            {
                Literal1.Text = "登录成功";
                //跳转到首页
                Response.Redirect("Index.aspx");
            }
            else
            {
                Literal1.Text = "输入错误，请重新输入";
            }

        }
    }
}